package com.sduept.bigdata.web;

import javax.el.PropertyNotFoundException;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.http.HttpStatus;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@SpringBootApplication
@ComponentScan(basePackages = { "com.sduept" })
@EntityScan(basePackages = { "com.sduept" })
@ServletComponentScan
@EnableTransactionManagement
@EnableCaching
@EnableScheduling
public class NwZdWebApplication  {

	public static void main(String[] args) {
		SpringApplication.run(NwZdWebApplication.class, args);
	}

	@Bean
	public WebServerFactoryCustomizer<ConfigurableWebServerFactory>  containerCustomizer() {    
		return new WebServerFactoryCustomizer<ConfigurableWebServerFactory>() {
            @Override
            public void customize(ConfigurableWebServerFactory factory) {
                factory.addErrorPages(new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error/error.xhtml")
                		,new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error/error.xhtml")
                		,new ErrorPage(HttpStatus.NOT_FOUND, "/error/404.xhtml")
                		,new ErrorPage(PropertyNotFoundException.class, "/error/error.xhtml")
                		);
            }
        };
	}
}
